﻿<#include "../common/layout/__mainlayout.html">
    <#include "../common/__pagination.html">

        <!--设置面包屑-->
        <#assign pageBreadCrumbs>
            <li class="active"><a href="#">应用管理</a></li>
<<<<<<< Updated upstream
            <li class="active">应用列表</li>
=======
>>>>>>> Stashed changes
        </#assign>


        <#assign pageCss>
            <!-- page specific plugin styles -->
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css"/>
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css"/>
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/datepicker.css"/>
            <link rel="stylesheet" href="${ctx}/static/admin/assets/css/daterangepicker.css"/>

        </#assign>

        <#assign pageJavascript>
            <script type="text/javascript">
                $(document).ready(function () {
                    //初始化范围选择器
                    $('input[name=createTimeRange]').daterangepicker({
                        'applyClass' : 'btn-sm btn-success',
                        'cancelClass' : 'btn-sm btn-default',
                        locale: {
                            applyLabel: '确定',
                            cancelLabel: '取消'
                        }
                    });

                    $("#payType").val(${query.payType!});
                    $("#safeState").val(${query.safeState!});
                    $("#softSrc").val(${query.softSrc!});
                    $("#isAccredit").val(${query.isAccredit!});
                    $("#state").val(${query.state!});
                    $("#checkAdminName").val(${query.checkAdminName!});
                    $("#categoryId").val(${query.categoryId!});
                    $("#categoryId2").val(${query.categoryId2!});
                    $("#categoryId3").val(${query.categoryId3!});


                    $("#categoryId").change(function () {
                        //清除二级下拉列表
                        $("#categoryId2").empty();
                        $("#categoryId3").empty();
                        if($(this).val() !=0){

                            $("#categoryId2").append($("<option/>").text("--请选择二级分类--").attr("value","0"));
                            //要请求的二级下拉JSON获取页面
                            var url="${ctx}/admin/category/categoryList.do";
                            //将选中的一级下拉列表项的id传过去
                            $.getJSON(url, { parentId:$(this).val() },function (data) {
                                //对请求返回的JSON格式进行分解加载
                                $(data.data).each(function () {
                                    $("#categoryId2").append($("<option/>").text(this.categoryName).attr("value",this.id));
                                });
                            });
                        }
                    });

                    $("#categoryId2").change(function () {
                        //清除二级下拉列表
                        $("#categoryId3").empty();
                        if($(this).val() !=0){
                            $("#categoryId3").append($("<option/>").text("--请选择三级分类--").attr("value","0"));
                            //要请求的二级下拉JSON获取页面
                            var url="${ctx}/admin/category/categoryList.do";
                            //将选中的一级下拉列表项的id传过去
                            $.getJSON(url, { parentId:$(this).val() },function (data) {
                                //对请求返回的JSON格式进行分解加载
                                $(data.data).each(function () {
                                    $("#categoryId3").append($("<option/>").text(this.categoryName).attr("value",this.id));
                                });
                            });
                        }

                    });

                    $('[data-rel=tooltip]').tooltip();

                    if (!ace.vars['touch']) {
                        $('.chosen-select').chosen({allow_single_deselect: true});
                    }

                    // 清除远程modal数据
                    $("#editModal").on("hidden.bs.modal", function () {
                        $(this).removeData("bs.modal");
                    });

                    // 删除按钮
                    $("a.delete").on(ace.click_event, function (e) {
                        submitClickListener(this,e,"删除");
                    });

                    // 上架按钮
                    $("a.upState").on(ace.click_event, function (e) {
                        submitClickListener(this,e,"上架");
                    });

                    // 下架按钮
                    $("a.downState").on(ace.click_event, function (e) {
                        submitClickListener(this,e,"下架");
                    });

                    // 显示按钮
                    $("a.showState").on(ace.click_event, function (e) {
                        submitClickListener(this,e,"展示");
                    });

                    // 隐藏按钮
                    $("a.hiddenState").on(ace.click_event, function (e) {
                        submitClickListener(this,e,"隐藏");
                    });

                    function submitClickListener(obj,e,title){
                        var currentA = obj;
                        e.preventDefault();
                        bootbox.confirm({
                                    message: "确定"+title+"该版本?",
                                    buttons: {
                                        confirm: {
                                            label: "确定",
                                            className: "btn-primary btn-sm"
                                        },
                                        cancel: {
                                            label: "取消",
                                            className: "btn-sm"
                                        }
                                    },
                                    callback: function (result) {
                                        if (result) {
                                            url = $(currentA).attr("href");
                                            $.get(url, { },function(data){
                                                if(data){
                                                    window.location.href=window.location.href;
                                                }
                                            });
                                        }
                                    }
                                }
                        );
                    }
                });
            </script>
        </#assign>

        <@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript
        currentMenu="ApplicationFlag-listSoft">
        <form id="searchForm" action="${ctx}/admin/soft/listSoft.html" class="form-search form-inline">
            <div class="row">
                <div class="widget-body">
                    <div class="widget-main">
                        <div class="form-group  col-xs-12" style="padding-top:10px">
                            <label class="col-xs-1 text-right">软件编号:</label>
                            <input type="number" id="id" name="id" class="input-sm col-xs-2" value="${query.id!}"/>
                            <label class="col-xs-1 text-right">软件名称:</label>
                            <input type="text" id="softName" name="softName" class="input-sm col-xs-2" value="${query.softName!}"/>
                            <label class="col-xs-1 text-right">开发者名称:</label>
                            <input type="text" id="developerName" name="developerName" class="input-sm col-xs-2" value="${query.developerName!}"/>
                            <label class="col-xs-1 text-right">软件包名:</label>
                            <input type="text" id="packageName" name="packageName" class="input-sm col-xs-2" value="${query.packageName!}"/>
                        </div>
                        <div class="form-group col-xs-12" style="padding-top:10px">
                            <label class="col-xs-1 text-right">搜索关键字:</label>
                            <input type="text" id="seo" name="seo" class="input-sm col-xs-2" value="${query.seo!}"/>
                            <label class="col-xs-1 text-right" for="isAccredit">是否授权:</label>
                            <select class="col-xs-2" name="isAccredit" id="isAccredit" data-placeholder="Choose a State..." >
                                <option value="-99" >请选择</option>
                                <option value="1" >是</option>
                                <option value="0" >否</option>
                            </select>
                            <label class="col-xs-1 text-right" for="createTimeRange">创建时间:</label>
                            <input type="text" class="col-xs-2"　value="${query.createTimeRange!}" name="createTimeRange" id="createTimeRange"/>
                        </div>

                        <div class="form-group col-xs-12" style="padding-top:10px">
                            <label class="control-label col-xs-12 col-sm-1 text-right" for="categoryId">软件分类:</label>
                            <select class="col-xs-2" name="categoryId" id="categoryId" data-placeholder="请选择一级分类">
                                <option value="0">--请选择一级分类--</option>
                                <#list firstCatagories as first>
                                    <option value="${first.id}" >
                                        ${(first.categoryName)!}
                                    </option>
                                </#list>
                            </select>
                            &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;
                            <select class="col-xs-2" name="categoryId2" id="categoryId2" data-placeholder="请选择二级分类">
                                <option value="0">请选择二级分类</option>
                                <#if secondCatagories??>
                                    <#list secondCatagories as sec>
                                        <option value="${sec.id}" >
                                            ${(sec.categoryName)!}
                                        </option>
                                    </#list>
                                </#if>
                            </select>
                            &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;
                            <select class="col-xs-2" name="categoryId3" id="categoryId3" data-placeholder="请选择三级分类">
                                <option value="0">请选择三级分类</option>
                                <#if thirdCatagories??>
                                    <#list thirdCatagories as third>
                                        <option value="${third.id}" >
                                            ${(third.categoryName)!}
                                        </option>
                                    </#list>
                                </#if>

                            </select>
                        </div>

                        <div class="form-group  col-xs-12" style="margin-bottom:2px;margin-top:2px">
                            <div class="col-xs-1 text-right" ><input type="button" id="searchBtn" class="btn btn-sm btn-primary" value="查询"/>&nbsp;</divcol-xs-1>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <table id="contentTable" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th width="40" align="center">软件编号</th>
                    <th width="60" align="left">软件名称</th>
                    <th width="60" align="left">软件包名</th>
                    <th width="40" align="left">下载量</th>
                    <th width="70" align="left">一级分类</th>
                    <th width="70" align="left">二级分类</th>
                    <th width="70" align="left">三级分类</th>
                    <th width="40" align="left">开发者</th>
                    <th width="40" align="left">创建时间</th>
                    <th width="200" align="center">操作</th>
                </tr>
                </thead>
                <tbody>
                <#list softs.listData as soft>
                    <#if softs??>
                        <tr>
                            <td width="60" align="left">${soft.id!}</td>
                            <td width="40" align="left">${soft.softName!}</td>
                            <td width="60" align="left">${soft.packageName!}</td>
                            <td width="40" align="left">${soft.downloadNumber!}</td>
                            <td width="70" align="left">${soft.firstCategoryName!}</td>
                            <td width="70" align="left">${soft.secCategoryName!}</td>
                            <td width="70" align="left">${soft.thirdCategoryName!}</td>
                            <td width="40" align="left">${soft.developerName!}</td>
                            <td width="40" align="left">${soft.createTimeShow!}</td>
                            <td>
                                <div class="hidden-sm hidden-xs action-buttons">
                                    <a class="green tooltip-success edit" href="${ctx}/admin/soft/editSoft.do?id=${soft.id!}" data-rel="tooltip" ><span class="label label-success">编辑</span></a>
                                    <a class="red tooltip-error delete" href="${ctx}/admin/soft/delSoft.do?id=${soft.id!}" data-rel="tooltip"> <span class="label label-danger">删除</span> </a>
                                    <a class="green tooltip-warning listSoftItems" href="${ctx}/admin/soft/listSoftItemsForWindow.do?softId=${soft.id!}"  data-rel="tooltip"  data-toggle="modal" data-target="#editModal"> <span class="label label-warning">软件版本</span></a>
                                    <a class="green tooltip-warning listSoftItems" href="${ctx}/admin/soft/viewRecommend.do?softId=${soft.id!}"  data-rel="tooltip"  data-toggle="modal" data-target="#editModal"> <span class="label label-warning">精品推荐</span></a>
<<<<<<< Updated upstream
=======
                                    <a class="green tooltip-warning listSoftItems" href="${ctx}/admin/softRecRank/addSoftRecRank.do?softId=${soft.id!}"  data-rel="tooltip"  data-toggle="modal" data-target="#editModal"> <span class="label label-warning">运营推荐</span></a>
>>>>>>> Stashed changes
                                </div>
                            </td>

                        </tr>
                    </#if>
                </#list>
                </tbody>
            </table>
            <@pagination softs!/>
        </form>
        <div id="editModal" class="modal fade">
            <div class="modal-dialog"style="width: 1200px;">
                <div class="modal-content">
                </div>
            </div>
        </div>
    </@mainlayout>